<?php
/**
 * 广告位类库.
 * User: mac
 * Date: 2018/6/19
 * Time: 18:39
 */

namespace app\api\controller;

class Common extends Api
{
    // 首页轮播广告位接口
    public function getads()
    {
        try {
            //查询数据库
            $ads = model("Ads")->getads();
        }catch(\Exception $e){
            return show(false,0,$e->getMessage());
        }

        //判定是否有数据
        if(!$ads){
            return show(false,0,'没有数据');
        }

        //拼接数据
        $res = array();
       foreach($ads as $k => $v){
            $res[$k]['AdverImg'] = 'https://course.51tiantiancai.cn/files/img/4406b68fcd61447a9938461b1f93d27b.gif';
            $res[$k]['AdverUrl'] = null;
       }

        //返回数据给前端
        return show(true,0,'',$res);
    }

    //生成海报上传图片
    public function upload(){
        //获取传递的图片
        /*$thumb = input('post.');
        //上传图片
        $info = request()->move('../uploads/poster/');
        if(!$info){
            return show(false,0,$file->getError());
        }
            return show(true,0,'',$info->getSaveName());*/
    }

    //购买须知
    public function getgmxz(){
        try{
            $config = model("WebConfig")->getgetgmxz();
        }catch(\Exception $e){
            return show(false,0,$e->getMessage());
        }

        //拼接数据
        $res = array(
            'Content' => $config['notes_to_buy'],
            'Title' => '购买须知'
        );
        return show(true,0,'Ok',$res);
    }
}